home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / flex_247.zip / flex_247 / MISC / testxxLexer.l < prev   
Text File  |  1993-10-03  |  823b  |  57 lines

  1.     // An example of using the flex C++ scanner class.
  2.  
  3. %{
  4. int mylineno = 0;
  5. %}
  6.  
  7. string    \"[^\n"]+\"
  8.  
  9. ws    [ \t]+
  10.  
  11. alpha    [A-Za-z]
  12. dig    [0-9]
  13. name    ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)*
  14. num1    [-+]?{dig}+\.?([eE][-+]?{dig}+)?
  15. num2    [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
  16. number    {num1}|{num2}
  17.  
  18. %%
  19.  
  20. {ws}    /* skip blanks and tabs */
  21.  
  22. "/*"        {
  23.         int c;
  24.  
  25.         while((c = yyinput()) != 0)
  26.             {
  27.             if(c == '\n')
  28.                 ++mylineno;
  29.  
  30.             else if(c == '*')
  31.                 {
  32.                 if((c = yyinput()) == '/')
  33.                     break;
  34.                 else
  35.                     unput(c);
  36.                 }
  37.             }
  38.         }
  39.  
  40. {number}    cout << "number " << YYText() << '\n';
  41.  
  42. \n        mylineno++;
  43.  
  44. {name}        cout << "name " << YYText() << '\n';
  45.  
  46. {string}    cout << "string " << YYText() << '\n';
  47.  
  48. %%
  49.  
  50. int main( int /* argc */, char** /* argv */ )
  51.     {
  52.     FlexLexer* lexer = new yyFlexLexer;
  53.     while(lexer->yylex() != 0)
  54.         ;
  55.     return 0;
  56.     }
  57.